home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 21
/
Cream of the Crop 21 (Terry Blount) (October 1996).iso
/
program
/
tsfaqp34.zip
/
FAQPAS3.TXT
< prev
next >
Wrap
Internet Message Format
|
1996-09-08
|
57KB
From ts@uwasa.fi Sun Sep 8 00:00:00 1996
Subject: FAQPAS3.TXT contents
Copyright (c) 1993-1996 by Timo Salmi
All rights reserved
FAQPAS3.TXT The third set of frequently (and not so frequently)
asked Turbo Pascal questions with Timo's answers. The items are in
no particular order.
You are free to quote brief passages from this file provided you
clearly indicate the source with a proper acknowledgment.
Comments and corrections are solicited. But if you wish to have
individual Turbo Pascal consultation, please post your questions to
a suitable Usenet newsgroup like news:comp.lang.pascal.borland. It
is much more efficient than asking me by email. I'd like to help,
but I am very pressed for time. I prefer to pick the questions I
answer from the Usenet news. Thus I can answer publicly at one go if
I happen to have an answer. Besides, newsgroups have a number of
readers who might know a better or an alternative answer. Don't be
discouraged, though, if you get a reply like this from me. I am
always glad to hear from fellow Turbo Pascal users.
....................................................................
Prof. Timo Salmi Co-moderator of news:comp.archives.msdos.announce
Moderating at ftp:// & http://garbo.uwasa.fi archives 193.166.120.5
Department of Accounting and Business Finance ; University of Vaasa
ts@uwasa.fi http://uwasa.fi/~ts BBS 961-3170972; FIN-65101, Finland
--------------------------------------------------------------------
51) I am running out of memory when compiling my large program.
52) How do I avoid scrolling in the last column of the last row?
53) How can one hide (or unhide) a directory using a TP program?
54) How do I test whether a file is already open in a TP program?
55) How can I test and convert a numerical string into a real?
56) How can I reverse a TP .EXE or .TPU back into source code?
57) How can I calculate the difference between two points of time?
58) Is a program running stand-alone or from within the IDE?
59) Please explain Turbo Pascal memory addressing to me.
60) How do I obtain a bit or bits from a byte, a word or a longint?
61) What are Binary Coded Decimals? How to convert them?
62) How can I copy a file in a Turbo Pascal program?
63) How can I use C code in my Turbo Pascal program?
64) How do I get started with the Turbo Profiler?
65) How can I detect if the shift/ctrl/alt etc key is pressed?
66) How do I get a base 10 logarithm in TP?
67) If Delay procedure does not work properly, how do I fix it?
68) How much memory will my TP program require?
69) How to detect if a drive is a CD-ROM drive?
70) How do I convert an array of characters into a string?
71) How do I get started with graphics programming?
72) Where to I find the different sorting source codes?
73) A beginner's how to write and compile units.
74) What are and how do I use pointers?
75) How can I read another program's errorlevel value in TP?
--------------------------------------------------------------------
From ts@uwasa.fi Sun Sep 8 00:00:51 1996
Subject: Out of memory in compiling
51. *****
Q: I am running out of memory when compiling my large program. What
can I do?
A: If you are compiling your program from within the IDE (the
Integrated Development Environment) then select the Option from the
main menu, choose the Compiler item and set the Link buffer to
Disk. (Also make the Compile option Destination to be Disk).
If this is not sufficient, next resort to using the TPC command
line version of the Turbo Pascal compiler instead of the IDE. Use
the "Link buffer on disk" option.
Divide your program into units. It is advisable anyway for
modularity when your program size grows.
If you have extended memory, instead of TURBO.EXE use TPX.EXE, if
you have TP 7.0. If you are into protected mode programming then use
Borland Pascal BP 7.0.
A2: If you would prefer compiling your program from within the IDE
but cannot do it for the above reason (or if you would prefer to
compile your program from within your favorite editor instead of the
TP IDE) you can use the following trick. If your editor has a macro
language like most good editors do, the assign a hotkey macro that
compiles the current file with the TPC. If you are using SemWare's
QEdit editor you'll find such macros in ("Macros and configurations
for QEdit text-editor") ftp://garbo.uwasa.fi/pc/ts/tsqed18.zip and
in ftp://garbo.uwasa.fi/ts/tstse18.zip ("SAL macro sources to extend
The SemWare Editor version 2.5").
Also your editor must be swapped to disk during the compilation
if memory is critical. There is a very good program for doing that:
ftp://garbo.uwasa.fi/pc/sysutil/shrom24b.zip ("Shell Room, Swap to
disk when shelling to application"). For example I invoke the QEdit
editor with using the following batch:
c:\tools\shroom -s r:\cmand -z 1024 c:\qedit\q %1 %2 %3 %4 %5 %6 %7
You'll find more about the switches in the Shell Room documentation.
The -s switch designates the swap destination (my r:\cmand directory
is on my ramdisk). The -z switch sets the shell environment size.
An unfortunate part is that the TP 5.0 Turbo Pascal IDE is about
the only program I know that is not amenable the to Shell Room
utility, so you cannot utilize Shell Room to swap the TP IDE to
disk. Blessfully, at least TP 7.0 no more has this problem.
--------------------------------------------------------------------
From ts@uwasa.fi Sun Sep 8 00:00:52 1996
Subject: Last position write woes
52. *****
Q: How do I avoid scrolling in the last column of the last row?
A: If you use write or writeln at the last column of the last row
(usually 80,25) the screen will scroll. If you wish to avoid the
scrolling you'll have to use an alternative write that does not move
the cursor. Here is a procedure to write without moving the cursor
uses Dos;
procedure WriteChar (Character : char; fgColor, bgColor : byte);
var r : registers;
begin
FillChar (r, SizeOf(r), 0);
r.ah := $09;
r.al := ord(Character);
r.bl := (bgColor shl 4) or fgColor;
r.cx := 1; { Number of repeats }
Intr ($10, r);
end; (* writechar *)
Thus, if you wish to write to the last column of the last row, you
must first move the cursor to that position. That can be done in
alternative ways. One might get there by having written previously
on the screen (with writeln and write routines) until one is in that
position. Another alternative is using GoToXY(80,20), but then you
have to use the Crt unit. If you don't want to use it, then you can
move the cursor by employing "GOATXY As the ordinary GoToXY but no
Crt unit required" from ftp://garbo.uwasa.fi/pc/ts/tspa3570.zip.
There is an alternative interrupt service ($0A) which does the
same as service $09, but uses the default colors instead. Just
substitute $0A for $09, and leave the r.bl assignment out of the
WriteChar routine.
Another option for writing anyhere on the screen without
affecting the cursor is using direct screen writes:
uses Dos;
procedure WriteChar (c : char; x, y : byte; fg, bg : byte);
var vidstart : word;
regs : registers;
begin
FillChar (regs, SizeOf(regs), 0);
regs.ah := $0F;
Intr ($10, regs); { Color or MonoChrome video adapter }
if regs.al = 7 then vidstart := $B000 else vidstart := $B800;
mem[vidstart:((y-1)*80+x-1)*2] := ord(c);
mem[vidstart:((y-1)*80+x-1)*2+1] := (bg shl 4) or fg;
end;
To write to the last position simply apply e.g.
WriteChar ('X', 80, 25, 14, 0); { Yellow on black }
The foreground (fg) and the background (bg) color codes are
Black = 0
Blue = 1
Green = 2
Cyan = 3
Red = 4
Magenta = 5
Brown = 6
LightGray = 7
DarkGray = 8
LightBlue = 9
LightGreen = 10
LightCyan = 11
LightRed = 12
LightMagenta = 13
Yellow = 14
White = 15
Blink = 128
Yet another option i